var mod_car = mod_fwk_base.extend({
	//idAttribute : 'id_car',
	defaults : function() {
		return {
			'name' : '',
			'cowl' : '',
			'note' : '',
			'wheelsFrontMeasure' : "0.00",
			'wheelsRearMeasure' : "0.00",
			'gear' : '5-1',
			'engine' : 'atomic',
			'brakes' : 'hard',
			'status': 'ready-to-race',
			'races': new Array(),
			'dateCreate' : new Date().getTime(),
			'dateMod' : new Date().getTime(),
			//TODO: add this
			'components': new Array()
		};
	},
	store: null,
	initialize: function(){
		this.store = __app.colls.cars.store;
		//this.on('change', this.setDateMod, this);
	},
	gear: function(){
	 	return __app.lists.gearTypes[this.attributes['gear']];
	},
	engine: function(){
		return __app.lists.engineTypes[this.attributes['engine']];
	},
	brakes: function(){
		return __app.lists.brakeTypes[this.attributes['brakes']];
	},
	status: function(){
		return __app.lists.carStatusTypes[this.attributes['status']];
	},
	addToRace: function(raceModel){
		if(typeof raceModel != 'undefined' && raceModel != null){
			var carsInRace = raceModel.get('cars');
			var joinedRaces = this.get('races');
			if(typeof this.id != 'undefined' && this.id != null){
				carsInRace = _.uniq(carsInRace.push(this.id))
				raceModel.set('cars', carsInRace);
			}else{
				return false;
			}
			if(typeof raceModel.id != 'undefined' && raceModel.id != null){
				joinedRaces = _.uniq(joinedRaces.push(raceModel.id));
				this.set('races', joinedRaces);
			}else{
				return false;
			}
			
			raceModel.save();
			this.save();
			return true;
		}
		return false;
	},
	validate: function(attrs, options){
	    var errors = new Array();
        if(attrs['name'] == null){
            errors.push({name: 'name', message: 'please enter a car name'});
        }
        if(attrs['cowl'] == null){
             errors.push({name: 'cowl', message: 'please enter a cowl name'});
        }
        
        if(errors.length > 0){
            return errors;
        }
	}
});